package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import pojo.JsonUtils;
import service.PictureService;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author Jordan裔
 * @create 2018-02-10 21:34
 **/
@Controller
public class PictureController {
    @Resource
    private PictureService pictureService;

    @RequestMapping("/pic/upload")
    @ResponseBody
    public String upLoadPicture(MultipartFile uploadFile){
        //调用service,上传图片
        Map<String,Object> upLoadPictureResult = pictureService.upLoadPicture(uploadFile);
        //为了各个浏览器的兼容性，将map转为json字符串再返回
        String jsonResult = JsonUtils.objectToJson(upLoadPictureResult);
        return  jsonResult;
    }
}
